using System;
using System.IO;
using ClearSpringNet.Util;

namespace ClearSpringNet.Stream
{
    [Serializable]
    public class Counter<T>
    {
        public ListNode2<StreamSummary<T>> bucketNode;
        public T getItem() { return item; }
        public long getCount() { return count; }
        public long getError() { return error; }

        public T item;
        public long count;
        public long error;

        public Counter()
        {
        }

        public Counter(ListNode2<StreamSummary<T>> bucket, T item)
        {
            bucketNode = bucket;
            count = 0;
            error = 0;
            this.item = item;
        }

        public String toString()
        {
            return item + ":" + count + ':' + error;
        }

        public void readExternal(BinaryReader input)
        {
            // item = input.Read()
            count = input.ReadInt64();
            error = input.ReadInt64();
        }

        public void writeExternal(BinaryWriter writer)
        {
            // writer.writeObject(item);
            writer.Write(count);
            writer.Write(error);
        }
    }
}